<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>V-for</title>
    <!-- 根据数据生成列表结构 -->
    <style>
        li{
            list-style: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <input type="button" value="添加数据" @click="add">
        <input type="button" value="移除数据" @click="remove">
        <ul>
            <li v-for="(it,index) in arr">
                {{index+1}} 中国城市: {{it}}
            </li>
        </ul>
          
        <h3 v-for="item in Vegetables" v-bind:title="item.name">
            {{item.name}}
        </h3>
    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                arr: ["北京", "上海", "广州", "深圳", "重庆", "成都", "济南"],
                Vegetables: [
                         {name:"蛋炒西红柿"},
                         {name:"煮饺子"}
                ]
            },
            methods: {
                 add:function(){
                     this.Vegetables.push({name:"花菜炒蛋"})
                 },
                 remove:function(){
                     this.Vegetables.shift();
                 }
            }
        })
    </script>
</body>

</html>